{extend name="base" /}
{block name="title"}
<title>忘记密码-{$site_config.site_title}</title>
{/block}
<link rel="stylesheet" type="text/css" href="__CSS__/base.css"/>
{block name="body"}
<style type="text/css">
.btn_code{width: 100%;margin: 0 auto;padding: 6px 10px;background: #ec5e2a;color: #fff;text-align: center;border-radius: 5px;}
</style>
    <div class="back">
        <a href="javascript:history.back(-1);"><img src="__STATIC__/img/back02.png" class="back_img"/></a>
    </div>
    <div class="login">
        <div class="login_bg">
            <div class="logo">
                <div class="logo_tit">
                    <img src="__STATIC__/img/logo.png" class="logo_imgs"/>
                </div>
            </div>
            <div class="login">
                <form id="h-form">
                    <ul>
                        <li>
                            <img src="__STATIC__/img/login_user.png"/>
                            <input type="text" placeholder="请输入手机号" name="mobile"  id="mobile" />
                        </li>
                        <li class="code">
                            <img src="__STATIC__/img/login_yezhengma.png"/>
                            <input type="text" placeholder="请填写验证码" class="input_t" name="code" style="width: 40%;" />
                            <!-- <img src="__STATIC__/img/btn_code.png" style="width:26%;"/> -->
                            <span id="timeObtain" class="btn_code"  >获取验证码</span>
                            <!-- <a id="timeObtain" class="btn_code" onclick="javascript:code();" >获取验证码</a> -->
                        </li>
                        <li>
                            <img src="__STATIC__/img/login_password.png"/>
                            <input type="password" placeholder="请输入新密码" name="new_pwd" />
                        </li>
                    </ul>
                    <div class="btn_login log_sty" style="margin-top:8%;">
                        <button type="button" class="b_login" id="h-submit">确认修改</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <script type="text/javascript">
	$("#timeObtain").click(function(){
		var pd=/^1\d{10}$/;
        if(pd.test($("#mobile").val())){
            $(".code span").removeAttr("onclick");
            $.ajax({
                url:"{:url('Home/MobileCode/getForgetMobileCode')}",
                type:"POST",
                data:{mobile:$("#mobile").val()},
                dataType:"json",
                success:function(data){
                    // 发送成功
                    if(data.status == 1) {
                        dialog.error(data.message,data.url);
                        $(".code span").css({"background":"#ddd","color":"#444"}).html("60秒重新发送").unbind("click");
                        var num=59;
                        var time=setInterval(function(){
                            $(".code span").html(num-- + "s后重新发送");
                            if(num<0){
                                clearTimeout(time);
                                $(".code span").css({"background":"#ec5e2a","color":"#fff"}).html("重新发送");
                                //$(".code span").attr("onclick","code()");
                            }
                        },1000);
                    }else if(data.status == 0) {
                        // 失败
                        dialog.error(data.message,data.url);
                        //$(".code span").attr("onclick","code()");
                        return false;
                    }
                }
            })
        }else{
            dialog.error("请输入正确的手机号码");
        }
	});

    </script>
    {include file="public/submit" /}
{/block}

